package com.zhao.controller;

import com.zhao.dao.DepartmentDao;
import com.zhao.dao.MajorDao;
import com.zhao.pojo.Admin;
import com.zhao.pojo.Department;
import com.zhao.pojo.Major;
import com.zhao.utils.JacksonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class MajorController {

    @Autowired
    private  MajorDao majorDao;

    @Autowired
    private DepartmentDao departmentDao;

    @ResponseBody
    @RequestMapping("getMajorList.do")
    public List<Major> getMajorList(String departmentID, HttpSession session){
        System.out.println("getmajor");
        Admin admin = (Admin)session.getAttribute("admin");
        List<Major> majorList = majorDao.findByDepartmentAndUniversityID(departmentID,admin.getUniversityID());
        System.out.println(majorList);
        String json = JacksonUtil.bean2Json(majorList);
        return majorList;
    }


}
